-
Notifications
You must be signed in to change notification settings - Fork 69
Explicit Auth Timeout Parameter #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit Auth Timeout Parameter #265
Conversation
|
So I get the need here, and it makes sense. However rather than add a very ad hoc |
I feel like if middlewares received the The problem is that passing a new parameter would break existing middewares :/ But maybe I should bite the bullet, and also pass a Hash as third argument so that it's easier to make it evolve in the future. It should also be able to check the middleware signature when they are registered, which should allow to fail early and ask users to update the signature, we might even be able to so some shenanigans to make them work in a degraded way. |
|
Actually, I'm an idiot, |
|
Can you try something like: module RedisAuthTimeoutMiddleware
def call_pipelined(commands, _config)
if commands.any? { |c| c.first == "AUTH" }
read_timeout_was = client.read_timeout
client.read_timeout = 1
begin
super
ensure
client.read_timeout = read_timeout_was
end
else
super
end
end
end |
|
From what I can tell, the connection prelude never goes through middlewares. It’s still run directly on the raw connection ( I’d happily switch to a middleware-based solution once the prelude is exposed to them; until then the auth_timeout knob is the only way to scope the higher budget without relaxing the global read/write timeouts.
I handled that by adding the context hash but only passing it when a middleware’s method signature accepts a third argument. Existing two-arg middlewares still get exactly the same call, while new ones can opt into the extra context. |
It very much does: redis-client/lib/redis_client.rb Lines 825 to 844 in 1ab0db0
That comment is outdated. I believe my example middleware would work, but if you have evidence it doesn't, please show me and I'll try to make the necessary change for it to work. |
|
Aha, awesome - let me do some digging! Thank you!
…On Fri, Nov 21, 2025 at 11:11 AM Jean Boussier ***@***.***> wrote:
*byroot* left a comment (redis-rb/redis-client#265)
<#265 (comment)>
From what I can tell, the connection prelude never goes through
middlewares.
It very much does:
https://github.com/redis-rb/redis-client/blob/1ab0db0751e30b0a18ed14395064bcfad2b5f134/lib/redis_client.rb#L825-L844
That comment is outdated.
I believe my example middleware would work, but if you have evidence it
doesn't, please show me and I'll try to make the necessary change for it to
work.
—
Reply to this email directly, view it on GitHub
<#265 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJIFLQZSKMV2JCHLOW4YOL3542SNAVCNFSM6AAAAACMW23FBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNRTG4YDQMZRGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Here's what worked! Thanks for the assist. I'll close this ticket: |
|
Perfect! |
For some services the steady-state
read_timeout/write_timeoutmust stay extremely low (30–60 ms) because higher values would break the business logic and fallback behavior already built around those limits. Unfortunately,AUTH—especially on TLS-backed ElastiCache with IAM authentication—can routinely take 30–200 ms. With today’s broad timeout knobs, the only way to avoid spuriousAUTHfailures is to relax theread|write_timeouts, which violates the SLA everywhere else.This change adds an
auth_timeoutconfiguration option that applies only to the connection prelude’sAUTHsteps (plainAUTHorHELLO). All other commands still use the existing read/write timeouts. That lets us bump the allowance for the handshake without touching the rest of the pipeline.Tests cover RESP2, RESP3, and mixed prelude cases, and the README now documents the new knob.